/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */

package panel;

import dto.Detalleventa;
import java.util.Hashtable;
import java.util.Vector;
import javax.swing.table.AbstractTableModel;

/**
 *
 * @author Joseco
 */
public class TableModelDetalle extends AbstractTableModel{
    
    private Vector<Detalleventa> detalle;
    private String[] cabeceras = {"Producto", "Precio", "Cantidad", "Subtotal"}; 
    
    public TableModelDetalle(Vector<Detalleventa> detalle){
        this.detalle = detalle;
    }

    @Override
    public int getRowCount() {
        return detalle.size();
    }

    @Override
    public int getColumnCount() {
        return 4;
    }

    @Override
    public Object getValueAt(int rowIndex, int columnIndex) {
        Detalleventa obj = detalle.get(rowIndex);
        switch(columnIndex){
            case 0:
                return obj.getDesripcionProducto();
            case 1:
                return new Double(obj.getPrecio());
            case 2:
                return new Integer(obj.getCantidad());
            case 3:
                return new Double(obj.getPrecio() * obj.getCantidad());
        }
        return "";
    }
    
    public String getColumnName(int col) {
        return cabeceras[col];
    }

    public Detalleventa getDetalleFromRow(int row){
        return detalle.get(row);
    }
    
}
